package com.onetech.adrewards.free.dialogs;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.onetech.adrewards.free.R;
import com.onetech.adrewards.free.activities.CommonWebViewInfoActivity;
import com.onetech.adrewards.free.config.AppConfig;
import com.onetech.adrewards.free.objects.UserInfoDTO;
import com.zuzu.dialogs.BaseDialog;

public class RegisterEmailConfirmDialog extends BaseDialog {
	
	
	protected View mBtnAgree=null;
	
	private View mBtnPolicy = null;
	private View mBtnPrivacy = null;
	private Activity mActivity=null;
	
	private UserInfoDTO mData=null;
	
	public RegisterEmailConfirmDialog(Activity context,UserInfoDTO dataUser){
		super(context, context.getString(R.string.register_email_confirm_title),
				TYPE_NO_BUTTON, R.layout.dialog_register_email_confirm);
		mActivity=context;
		if(dataUser==null){
			dismiss();
		}
		mData=dataUser;
		
		initView();
		initListener();
		

		
	}	
	private void initView() {
		
	
		mBtnAgree = (LinearLayout)findViewById(R.id.btnAgree);
		mBtnPolicy = (RelativeLayout) findViewById(R.id.btnPolicy);
		mBtnPrivacy = (RelativeLayout) findViewById(R.id.btnPrivacy);
		
				
	}
	private void initListener() {
		mBtnAgree.setOnClickListener(this);
		mBtnPolicy.setOnClickListener(this);
		mBtnPrivacy.setOnClickListener(this);
		
	}
	
	
	@Override
	public void onClick(View v) {
		int id = v.getId();
		if(id == R.id.btnAgree)
		{
			dismiss();
			RegisterEmailDialog register = new RegisterEmailDialog(mActivity, mData);
			register.show();
		}
		else if(id == R.id.btnPolicy)
		{
			String url = AppConfig.URLRequestApi.GET_STATIC_PAGE + "3";
			Intent intent=new Intent(mActivity, CommonWebViewInfoActivity.class);
			intent.putExtra("URL", url);
			intent.putExtra("ViewTitle", mActivity.getString(R.string.policy_title));
			mActivity.startActivity(intent);
		}
		else if(id == R.id.btnPrivacy)
		{
			String url = AppConfig.URLRequestApi.GET_STATIC_PAGE + "5";
			Intent intent=new Intent(mActivity, CommonWebViewInfoActivity.class);
			intent.putExtra("URL", url);
			intent.putExtra("ViewTitle", mActivity.getString(R.string.privacy_title));
			mActivity.startActivity(intent);
		}
		else {
			
			super.onClick(v);
	
		}
	}
	
	
	
	
}
